package cn.cvs.service.impl;

import cn.cvs.dao.SysUserMapper;
import cn.cvs.pojo.SysUser;
import cn.cvs.service.SysUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
//@Transactional/*事务注解（推荐使用配置事务）*/
@Service("sysUserService")
public class SysUserServiceImpl implements SysUserService {
    @Resource
    private SysUserMapper sysUserMapper;


    @Override
    public List<SysUser> getUserByNameAndRoleId(String name, Integer id, Integer pageIndex, Integer pageSize) {
        return sysUserMapper.getUserByNameAndRoleId(name, id, (pageIndex-1)*pageSize, pageSize);
    }

    @Override
    public int addUser(SysUser sysUser) {
        return sysUserMapper.addUser(sysUser);
    }

    @Override
    public int delUser(Integer id) {
        return sysUserMapper.delUser(id);
    }

    @Override
    public int updUser(SysUser sysUser) {
        return sysUserMapper.updUser(sysUser);
    }

    @Override
    public SysUser getUserById(Integer id) {
        return sysUserMapper.getUserById(id);
    }

    @Override
    public SysUser login(String name, String pwd) {
        return sysUserMapper.login(name, pwd);
    }

    @Override
    public int getCountByNameAndRoleId(String name, Integer id) {
        return sysUserMapper.getCountByNameAndRoleId(name, id);
    }

    @Override
    public int updLoginPwd(String pwd, Integer id) {
        return sysUserMapper.updLoginPwd(pwd, id);
    }

    @Override
    public List<SysUser> getUserByName(String name) {
        return sysUserMapper.getUserByName(name);
    }

    @Override
    public int getUserByRoleId(Integer roleId) {
        return sysUserMapper.getUserByRoleId(roleId);
    }
}
